package com.sdhs.examinemanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.examinemanage.domain.GcExamineSupplier;
import com.sdhs.examinemanage.service.IGcExamineSupplierService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 供应商考核Controller
 * 
 * @author wanglei
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/examinemanage/examineSupplier")
public class GcExamineSupplierController extends BaseController
{
    @Autowired
    private IGcExamineSupplierService gcExamineSupplierService;

    /**
     * 查询供应商考核列表
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcExamineSupplier gcExamineSupplier)
    {
        startPage();
        List<GcExamineSupplier> list = gcExamineSupplierService.selectGcExamineSupplierList(gcExamineSupplier);
        return getDataTable(list);
    }

    /**
     * 导出供应商考核列表
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:export')")
    @Log(title = "供应商考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcExamineSupplier gcExamineSupplier)
    {
        List<GcExamineSupplier> list = gcExamineSupplierService.selectGcExamineSupplierList(gcExamineSupplier);
        ExcelUtil<GcExamineSupplier> util = new ExcelUtil<GcExamineSupplier>(GcExamineSupplier.class);
        util.exportExcel(response, list, "供应商考核数据");
    }

    /**
     * 获取供应商考核详细信息
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcExamineSupplierService.selectGcExamineSupplierById(id));
    }

    /**
     * 新增供应商考核
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:add')")
    @Log(title = "供应商考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcExamineSupplier gcExamineSupplier)
    {
        return toAjax(gcExamineSupplierService.insertGcExamineSupplier(gcExamineSupplier));
    }

    /**
     * 修改供应商考核
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:edit')")
    @Log(title = "供应商考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcExamineSupplier gcExamineSupplier)
    {
        return toAjax(gcExamineSupplierService.updateGcExamineSupplier(gcExamineSupplier));
    }

    /**
     * 删除供应商考核
     */
    @PreAuthorize("@ss.hasPermi('examinemanage:examineSupplier:remove')")
    @Log(title = "供应商考核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcExamineSupplierService.deleteGcExamineSupplierByIds(ids));
    }
}
